﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HHUpdateApp
{
    public partial class ProgressBarEx : ProgressBar
    {
        public ProgressBarEx()
        {
            this.SetStyle(ControlStyles.UserPaint, true);
            //InitializeComponent();
        }
        private SolidBrush brush = null;
        protected override void OnPaint(PaintEventArgs e)
        {
            //LinearGradientBrush brush = null;
            //Rectangle rec = new Rectangle(0, 0, this.Width, this.Height);
            //double scaleFactor = (((double)Value - (double)Minimum) / ((double)Maximum - (double)Minimum));

            //if (ProgressBarRenderer.IsSupported)
            //    ProgressBarRenderer.DrawHorizontalBar(e.Graphics, rec);

            //rec.Width = (int)((rec.Width * scaleFactor) - 4);
            //rec.Height -= 4;
            //brush = new LinearGradientBrush(rec, this.ForeColor, this.BackColor, LinearGradientMode.Vertical);
            //e.Graphics.FillRectangle(brush, 2, 2, rec.Width, rec.Height);


            Rectangle rec = e.ClipRectangle;
            rec.Width = (int)(rec.Width * ((double)Value / Maximum)) - 4;
            if (ProgressBarRenderer.IsSupported)
                ProgressBarRenderer.DrawHorizontalBar(e.Graphics, e.ClipRectangle);
            rec.Height = rec.Height - 4;
            e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(26, 173, 25)), 2, 2, rec.Width, rec.Height);

        }
    }
}
